package com.lark.algorithm.common.domain.letcode;

import lombok.Data;

/**
 * @author btmood
 * @version 1.0
 * @apiNote
 * @since 2024-05-30 16:29
 */
@Data
public class ListNode {
    public int val;
    public ListNode next;
    public ListNode() {}
    public ListNode(int val) { this.val = val; }
    public ListNode(int val, ListNode next) { this.val = val; this.next = next; }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(val);
        sb.append("=>");
        ListNode curNode = next;
        while (curNode != null) {
            sb.append(curNode.val);
            sb.append("=>");
            curNode = curNode.next;
        }
        sb.append("null");
        return sb.toString();
    }
}
